module("AccountUI", package.seeall)

local accountName = "test"
local accountPasswd = "test"
local loginStatus = "logined"

function getAccountName()
	return accountName
end

function getLoginStatus()
	return loginStatus;
end

function onButtonLoginClick(self)
	accountName = self._textfieldName:getStringValue()
	loginStatus = "logined"
	LoginScene.showUILayer(self._loginScene, LoginHomeUI)
end

function create(scene)
	local self = ccs.GUIReader:getInstance():widgetFromJsonFile("res/UI/LoginUI/AccountUI.ExportJson")
	self._loginScene = scene
	init(self)
	return self
end

function init(self)
	self._button_login = self:getChildByName("Button_Login")
	--self._button_server = self:getChildByName("Button_Server")
	self._panelMain = self:getChildByName("Panel_Main")
	self._textfieldName = self._panelMain:getChildByName("TextField_Name")
	self._textfieldPasswd = self._panelMain:getChildByName("TextField_Passwd")

	self._textfieldName:setText(accountName)
	self._textfieldPasswd:setText(accountPasswd)

	self._button_login:addTouchEventListener(
		function(sender, eventType)
			if (eventType == ccui.TouchEventType.ended) then
				onButtonLoginClick(self)
			end
		end)
end